puts "Enter Number of Terms"
n=gets.chomp
n=n.to_f
puts "Enter 1st Term"
a=gets.chomp
a=a.to_f
puts "Enter 2nd Term"
b=gets.chomp
b=b.to_f
puts "Enter 3rd Term"
c=gets.chomp
c=c.to_f
d1=b-a
d2=c-b
r1=b/a
r2=c/b

if d1==d2
  s=(n/2)*(2*a+(n-1)*d1)
  puts "The sum of the series is "+s.to_s

elsif r1==r2
  s=(a*(r1**n-1))/(r1-1)
  puts "The sum of the series is "+s.to_s

else
  puts "This is not a valid series!"
end
